/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.uoc.tdp.client.informes;

import edu.uoc.tdp.beans.conexio.Estudiant;
import edu.uoc.tdp.beans.informes.Universitat;
import edu.uoc.tdp.beans.proves.Prova;
import edu.uoc.tdp.common.EOlympicsException;
import edu.uoc.tdp.common.EOlympicsUtils;
import edu.uoc.tdp.common.RemotInformesInterface;
import edu.uoc.tdp.common.TDSLanguageUtils;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 * Informe que permet als usuaris de perfil estudiant, obtenir el llistat dels resultats de les proves en les que l’estudiant connectat s’ha inscrit fins la data de consulta. La informació mostrada en l’informe, a banda del nom i cognoms de l’estudiant
 * @author joboni
 */
public class PantallaMevesProves extends javax.swing.JFrame {
    
    private RemotInformesInterface remot;
    private DefaultTableModel dtm;
    private javax.swing.JTable jTable1;
    private javax.swing.JScrollPane jScrollPane2;
    private Estudiant estudiant;
    /**
     * Creates new form PantallaMevesProves
     */
    public PantallaMevesProves(Estudiant estudiant) {
        try {
            this.estudiant = estudiant;
            initComponents();
            inicialitzarComponets();
        } catch (MalformedURLException e) {
            JOptionPane.showMessageDialog(null, TDSLanguageUtils.getMessage("informes.ERR_RMI_URL"), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (NotBoundException e) {
            JOptionPane.showMessageDialog(null, TDSLanguageUtils.getMessage("informes.ERR_RMI_INIT"), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (RemoteException e) {
            JOptionPane.showMessageDialog(null, TDSLanguageUtils.getMessage("informes.ERR_REMOT"), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
    
    /**
     * Metode per inicialitzar els components de la pantalla ( Literalas, mides, taules...)
     * @throws IOException
     * @throws NotBoundException
     * @throws RemoteException
     * @throws EOlympicsException 
     */
    private void inicialitzarComponets() throws IOException, NotBoundException, RemoteException, EOlympicsException{
        //Literals
        TDSLanguageUtils.setDefaultLanguage("edu/uoc/tdp/i18n/messages");
        setTitle(TDSLanguageUtils.getMessage("informes.titol"));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(TDSLanguageUtils.getMessage("informes.filtre")));
        jLabel1.setText(TDSLanguageUtils.getMessage("informes.mevesproves.subtitol"));
        jLabel2.setText(TDSLanguageUtils.getMessage("informes.nom"));
        jLabel8.setText(TDSLanguageUtils.getMessage("informes.cognom"));
        jLabel9.setText(this.estudiant.getNom());
        jLabel10.setText(this.estudiant.getCognom1()+" "+this.estudiant.getCognom2());
        jLabel11.setText(TDSLanguageUtils.getMessage("informes.tipus"));
        jLabel3.setText(TDSLanguageUtils.getMessage("informes.prova"));
        jLabel4.setText(TDSLanguageUtils.getMessage("informes.dinscripciofins"));
        jLabel5.setText(TDSLanguageUtils.getMessage("informes.drealitzaciofins"));
        jLabel6.setText(TDSLanguageUtils.getMessage("informes.fins"));
        jLabel7.setText(TDSLanguageUtils.getMessage("informes.fins"));
        jTextField1.setText(TDSLanguageUtils.getMessage("informes.formatdata"));   
        jTextField2.setText(TDSLanguageUtils.getMessage("informes.formatdata"));   
        jTextField3.setText(TDSLanguageUtils.getMessage("informes.formatdata"));   
        jTextField4.setText(TDSLanguageUtils.getMessage("informes.formatdata"));   
        jButton1.setText(TDSLanguageUtils.getMessage("informes.filtrar"));   
        //Conexió RMI
        Properties prop = new Properties();
        URL url = ClassLoader.getSystemResource("edu/uoc/tdp/properties/configuration.properties");
        prop.load(url.openStream());
        remot=(RemotInformesInterface)Naming.lookup(prop.getProperty("pathrmi_informes"));
        //Combo de tipus de prova
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { null, "E", "F" }));
        //Recuperem les proves de l'estudiant
        List<Prova> proves = remot.getMevesProves(this.estudiant.getIdIntern());
        proves.add(0,new Prova(null, ""));
        
        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(proves.toArray()));
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable1 = new JTable(dtm);
        jTable1.setAutoCreateRowSorter(true);
        jScrollPane2.setViewportView(jTable1);
        //Tamany de la taula
        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
                .addContainerGap())
        );
        actualitzarTaula(null,null,null,null,null,null);
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    }
    /**
     * Método per actualitzar el contingut de la taula. Mostra els resultats a partir dels camps introduits per pantalla
     * @param tipus
     * @param idProva
     * @param dinscripcio_ini
     * @param dinscripcio_fi
     * @param drealitacio_ini
     * @param drealitacio_fi
     * @throws RemoteException
     * @throws EOlympicsException 
     */
    private void actualitzarTaula(String  tipus, Integer idProva, Date dinscripcio_ini,
            Date dinscripcio_fi, Date drealitacio_ini, Date drealitacio_fi) throws RemoteException, EOlympicsException{
        //Recuperem les dades de la BBDD
        ArrayList<HashMap> resultats = remot.consultarMevesProves(tipus,idProva,
                dinscripcio_ini,dinscripcio_fi,drealitacio_ini,drealitacio_fi, this.estudiant.getIdIntern());
        //Columnes de la taula
        String [] columnes = new String [] {
                "",
                TDSLanguageUtils.getMessage("informes.prova"),
                TDSLanguageUtils.getMessage("informes.tipus"),
                TDSLanguageUtils.getMessage("informes.preguntes"),
                TDSLanguageUtils.getMessage("informes.places"),
                TDSLanguageUtils.getMessage("informes.drealitzacio"),
                TDSLanguageUtils.getMessage("informes.encerts"),
                TDSLanguageUtils.getMessage("informes.errors"),
                TDSLanguageUtils.getMessage("informes.blanc"),
            };
        Object [][] dades = new Object [resultats.size()][10];
        
        //Model de la taula
        dtm =(new javax.swing.table.DefaultTableModel(
            dades,columnes
        ) {
            @Override
                public boolean isCellEditable(int rowIndex, int columnIndex) {
                return false;
                }
        });
        jTable1.setModel(dtm);
        int i = 0;
        //REcuperem les dades de la consulta i les introduim a la taula
        for (HashMap resultat : resultats){
            dtm.setValueAt(resultat.get("IDPROVA"), i, 0);
            dtm.setValueAt(resultat.get("DESCRIPCIO"), i, 1);
            dtm.setValueAt(resultat.get("TIPUS"), i, 2);
            dtm.setValueAt(resultat.get("NUMPREGUNTES"), i, 3);
            dtm.setValueAt(resultat.get("NUMPLACES"), i, 4);
            dtm.setValueAt(resultat.get("DATAPARTICIPACIO"), i, 5);
            dtm.setValueAt(resultat.get("ENCERTS"), i, 6);
            dtm.setValueAt(resultat.get("ERRORS"), i, 7);
            dtm.setValueAt(resultat.get("BLANC"), i, 8);
            i++;
            
        }
        //Introduiem la captura de click en les files de la taula i obre el detall de la prova
        jTable1.addMouseListener(new java.awt.event.MouseAdapter(){
            public void mouseClicked(java.awt.event.MouseEvent e){
                int row=jTable1.rowAtPoint(e.getPoint());
                PantallaDetallProva pantalla = new PantallaDetallProva(new Integer(jTable1.getValueAt(row,0).toString()), jTable1.getValueAt(row,2).toString());
                pantalla.setLocationRelativeTo(null);
                pantalla.setVisible(true);
            }   

        });
        //Amagem la primera columna
        jTable1.getColumnModel().getColumn(0).setMaxWidth(0);
	jTable1.getColumnModel().getColumn(0).setMinWidth(0);
        jTable1.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
        jTable1.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
        if (resultats.size()<=0){
            JOptionPane.showMessageDialog(null,TDSLanguageUtils.getMessage("informes.noresultats"));
        }
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jPanel3 = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Resultat proves finalitzades");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setText("Universitat");

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel8.setText("jLabel8");

        jLabel9.setText("jLabel9");

        jLabel10.setText("jLabel10");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(29, 29, 29)
                        .addComponent(jLabel9)
                        .addGap(45, 45, 45)
                        .addComponent(jLabel8)
                        .addGap(30, 30, 30)
                        .addComponent(jLabel10)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jLabel1)
                .addGap(31, 31, 31)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel9)
                    .addComponent(jLabel8)
                    .addComponent(jLabel10))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel3.setText("Prova");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setText("jLabel4");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel5.setText("jLabel5");

        jTextField1.setText("jTextField1");
        jTextField1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField1FocusLost(evt);
            }
        });

        jTextField2.setText("jTextField2");
        jTextField2.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField2FocusLost(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel6.setText("jLabel6");

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel7.setText("jLabel7");

        jTextField3.setText("jTextField3");
        jTextField3.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField3FocusLost(evt);
            }
        });

        jTextField4.setText("jTextField4");
        jTextField4.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField4FocusLost(evt);
            }
        });

        jButton1.setText("jButton1");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel11.setText("jLabel11");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "E", "F" }));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(71, 71, 71))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(59, 59, 59)))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel4))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel5)))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel6)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel7)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 103, Short.MAX_VALUE)
                        .addComponent(jButton1)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(14, Short.MAX_VALUE)
                .addComponent(jLabel3)
                .addGap(18, 18, 18)
                .addComponent(jLabel11)
                .addGap(64, 64, 64))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 182, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    /**
     * Métode per inicialitzar el camp data a dd/mm/yyy del camp inici inscripció
     * @param evt 
     */
    private void jTextField1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField1FocusLost
        if(!EOlympicsUtils.isValidDate(jTextField1.getText().trim())){
            jTextField1.setText(TDSLanguageUtils.getMessage("informes.formatdata"));
        }
    }//GEN-LAST:event_jTextField1FocusLost
    /**
     * Métode per inicialitzar el camp data a dd/mm/yyy del camp fi inscripció
     * @param evt 
     */    
    private void jTextField2FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField2FocusLost
        if(!EOlympicsUtils.isValidDate(jTextField2.getText())){
            jTextField2.setText(TDSLanguageUtils.getMessage("informes.formatdata"));
        }        
    }//GEN-LAST:event_jTextField2FocusLost
    /**
     * Métode per inicialitzar el camp data a dd/mm/yyy del camp inici realització
     * @param evt 
     */
    private void jTextField3FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField3FocusLost
        if(!EOlympicsUtils.isValidDate(jTextField3.getText())){
            jTextField3.setText(TDSLanguageUtils.getMessage("informes.formatdata"));
        }        
    }//GEN-LAST:event_jTextField3FocusLost
    /**
     * Métode per inicialitzar el camp data a dd/mm/yyy del camp fi realització
     * @param evt 
     */
    private void jTextField4FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField4FocusLost
        if(!EOlympicsUtils.isValidDate(jTextField4.getText())){
            jTextField4.setText(TDSLanguageUtils.getMessage("informes.formatdata"));
        } 
    }//GEN-LAST:event_jTextField4FocusLost
   /**
     * Métode que recuperar els camps de la pantalla un cop s'ha fet click en el butó buscar.
     * @param evt 
     */
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        try {
            String tipus = ((String)jComboBox1.getSelectedItem());
            Prova prova = ((Prova)jComboBox2.getSelectedItem());
            Date dinscripcioinit = null;
            if(EOlympicsUtils.isValidDate(jTextField1.getText().trim())){
                dinscripcioinit = EOlympicsUtils.getDateSimpleFormat(jTextField1.getText().trim());
            }
            Date dinscripciofin = null;
            if(EOlympicsUtils.isValidDate(jTextField3.getText().trim())){
                dinscripciofin = EOlympicsUtils.getDateSimpleFormat(jTextField3.getText().trim());
            }
            
            Date drealitzacioinit = null;
            if(EOlympicsUtils.isValidDate(jTextField2.getText().trim())){
                drealitzacioinit = EOlympicsUtils.getDateSimpleFormat(jTextField2.getText().trim());
            }
            Date drealitzaciofin = null;
            if(EOlympicsUtils.isValidDate(jTextField4.getText().trim())){
                drealitzaciofin = EOlympicsUtils.getDateSimpleFormat(jTextField4.getText().trim());
            }
            //Actualitzem la taula
            actualitzarTaula(tipus, prova.getIdProva(),dinscripcioinit,dinscripciofin,drealitzacioinit,drealitzaciofin );
        } catch (RemoteException ex) {
            JOptionPane.showMessageDialog(null, TDSLanguageUtils.getMessage("informes.ERR_REMOT"), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (EOlympicsException ex) {
            JOptionPane.showMessageDialog(null, TDSLanguageUtils.getMessage("informes.ERROR"), "Error", JOptionPane.ERROR_MESSAGE);
        }

    }//GEN-LAST:event_jButton1ActionPerformed

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    // End of variables declaration//GEN-END:variables
}



